package com.yangwp.jie.common.utils;

import com.google.common.collect.Maps;
import com.yangwp.jie.common.enums.RetCodeEnum;

import java.util.Map;

public class MapUtils {

    public static Map<String, Object> getRetMap(){
        Map<String, Object> map = Maps.newHashMap();
        return map;
    }

    public static Map<String, Object> getRetMap(RetCodeEnum codeEnum){
        Map<String, Object> map = Maps.newHashMap();
        map.put("code", codeEnum.getCode());
        map.put("msg", codeEnum.getDesc());
        return map;
    }

    public static Map<String, Object> getRetMap(RetCodeEnum codeEnum, String msg){
        Map<String, Object> map = Maps.newHashMap();
        map.put("code", codeEnum.getCode());
        map.put("msg", msg);
        return map;
    }

    public static Map<String, Object> getRetMap(RetCodeEnum codeEnum, String msg, Object data){
        Map<String, Object> map = Maps.newHashMap();
        map.put("code", codeEnum.getCode());
        map.put("msg", msg == null ? codeEnum.getDesc() : msg);
        map.put("data", data);
        return map;
    }

}
